﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
using MyDBconnection;
using System.IO;


namespace CamposInventory
{
    
    public partial class frmConnection : Form
    {
        
        DatabaseConnection dbcon = new DatabaseConnection();
        settings server = new settings();
        
        public frmConnection()
        {
            InitializeComponent();
            this.Load += new EventHandler(frmConnection_Load);
            btnok.Click += new EventHandler(btnok_Click);
        }
 
        
        void btnok_Click(object sender, EventArgs e)
        {
            
            StreamWriter writer = new StreamWriter("Connection_Settings.txt");
            writer.WriteLine(txthostname.Text);
            writer.WriteLine(txtdbname.Text);
            writer.WriteLine(txtuser.Text);
            writer.WriteLine(txtpass.Text);
            writer.Close();


            server.host = txthostname.Text;
            server.db = txtdbname.Text;
            server.uid = txtuser.Text;
            server.pass = txtpass.Text;
            this.Close();
           
        }

        void frmConnection_Load(object sender, EventArgs e)
        {
            string[] settings = File.ReadAllLines(@".\\Connection_Settings.txt");
            txthostname.Text = settings[0];
            txtdbname.Text = settings[1];
            txtuser.Text = settings[2];
            txtpass.Text = settings[3];
           
        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }
        
    }
}
